package com.wuyan.locationdog.ui.device

import androidx.activity.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.arcsoft.commonbase.base.BaseBindingActivity
import com.arcsoft.commonbase.ext.createEmptyView
import com.arcsoft.commonbase.ext.customShowLong
import com.blankj.utilcode.util.ToastUtils
import com.wuyan.locationdog.R
import com.wuyan.locationdog.adapter.AlarmListAdapter
import com.wuyan.locationdog.databinding.DeviceAlarmListActivityBinding
import com.wuyan.locationdog.viewmodel.DeviceViewModel


class ModeSetListActivity : BaseBindingActivity<DeviceAlarmListActivityBinding>() {
    private val mViewModel: DeviceViewModel by viewModels()

    private val mAdapter by lazy { AlarmListAdapter(R.layout.item_alarm_list, null) }

    override fun initData() {
//        val deviceBeanContent = intent.getSerializableExtra("DeviceBeanContent") as DeviceBeanContent

        setTitleText("模式切换")


        binding.apply {

            recyclerView.apply {
                layoutManager = LinearLayoutManager(context)
                adapter = mAdapter.apply {
                    setEmptyView(createEmptyView("暂无消息"))


                    setOnItemClickListener { adapter, view, position ->

                    }
                }
            }
            btnSure.setOnClickListener {

            }

        }

//        val map = HashMap<String, Any>()
//        map["deviceId"] = deviceBeanContent.deviceId
//        mViewModel.deviceAlarmSet(map)
    }

    override fun observe() {
        super.observe()

        mViewModel.deviceAlarmSetBean.observe(this) {
//            if (!it.content.isNullOrEmpty()) {
//                DeviceHelp.instantDeviceAlarmSetBeanContent = it.content.first()
//            }
//            val list = mutableListOf<AlarmNameBean>()
//            list.add(AlarmNameBean("低电报警 (无线设备)",R.mipmap.alert_dianchi,it.content[0]))
//            list.add(AlarmNameBean("拆除报警",R.mipmap.alert_dianchi,it.content[1]))
//            list.add(AlarmNameBean("超速报警 (80km/h)",R.mipmap.alert_dianchi,it.content[2]))
//            list.add(AlarmNameBean("进围栏区域报警",R.mipmap.alert_dianchi,it.content[3]))
//            list.add(AlarmNameBean("出围栏区域报警",R.mipmap.alert_dianchi,it.content[4]))
            mAdapter.setNewInstance(it.content.toMutableList())
        }

        mViewModel.anyBean.observe(this) {
            customShowLong("成功")
            finish()
        }
    }

}